<?php 
class Module
{
	public $Id;
	public $SetId;
	public $SiteId;
	public $ModId;
	public $NameL;
	public $NameR;
	public $Path;
	public $Icon;
	public $Type;
	public $HFB;
	public $Active;
	public $ObjectType;
	public $ContentId;
	public $Max;
	public $Cols;
	public $Rows;
	public $Indexing;
	public $ButtonsHeader;
	public $ButtonsFooter;
	public $ButtonsContent;
	public $Settings;
	public $FormFields;
	public $FormError;
	public $FormInfo;
	
	
	public function Module($katana, $id) 
	{ 
		self::setSiteId($katana->GetId());
		if($id > 0)
		{
			self::setModId($id);
			self::loadModule($katana);
		}
	}
	
	public function getId() { return $this->Id; }
	public function getSetId() { return $this->SetId; }
	public function getSiteId() { return $this->SiteId; }
	public function getModId() { return $this->ModId; }
	public function getNameL() { return $this->NameL; }
	public function getNameR() { return $this->NameR; }
	public function getPath() { return $this->Path; }
	public function getIcon() { return $this->Icon; }
	public function getType() { return $this->Type; }
	public function getHFB() { return $this->HFB; }
	public function getActive() { return $this->Active; }
	public function getObjectType() { return $this->ObjectType; }
	public function getContentId() { return $this->ContentId; }
	public function getMax() { return $this->Max; }
	public function getCols() { return $this->Cols; }
	public function getRows() { return $this->Rows; }
	public function getIndexing() { return $this->Indexing; }
	public function getButtonsHeader() { return $this->ButtonsHeader; }
	public function getButtonsFooter() { return $this->ButtonsFooter; }
	public function getButtonsContent() { return $this->ButtonsContent; }
	public function getButtonContent($index) 
	{
		if(isset($this->ButtonsContent[$index]))
		{ return $this->ButtonsContent[$index]; }
	}
	public function getSettings() { return $this->Settings; }
	public function getFormFields() { return $this->FormFields; }
	public function getFormError() { return $this->FormError; }
	public function getFormInfo() { return $this->FormInfo; }
	
	public function setId($val) { $this->Id=$val; }
	public function setSetId($val) { $this->SetId=$val; }
	public function setSiteId($val) { $this->SiteId=$val; }
	public function setModId($val) { $this->ModId=$val; }
	public function setNameL($val) { $this->NameL=$val; }
	public function setNameR($val) { $this->NameR=$val; }
	public function setPath($val) { $this->Path=$val; }
	public function setIcon($val) { $this->Icon=$val; }
	public function setType($val) { $this->Type=$val; }
	public function setHFB($val) { $this->HFB=$val; }
	public function setActive($val) { $this->Active=$val; }
	public function setObjectType($val) { $this->ObjectType=$val; }
	public function setContentId($val) { $this->ContentId=$val; }
	public function setMax($val) { $this->Max=$val; }
	public function setCols($val) { $this->Cols=$val; }
	public function setRows($val) { $this->Rows=$val; }
	public function setIndexing($val) { $this->Indexing=$val; }
	public function setButtonsHeader($val) { $this->ButtonsHeader=$val; }
	public function setButtonsFooter($val) { $this->ButtonsFooter=$val; }
	public function setButtonsContent($val) { $this->ButtonsContent=$val; }
	public function setSettings($val) { $this->Settings=$val; }
	public function setFormError($val) { $this->FormError=$val; }
	public function setFormInfo($val) { $this->FormInfo=$val; }
	
	
	public function loadModule($katana) 
	{ 
		if(($this->SiteId > 0) && ($this->ModId > 0))
		{	
			$select = 'SELECT * FROM '.DB_PERFIX.'modules WHERE site_id='.$this->SiteId.' AND mod_id='.$this->ModId.' LIMIT 1;';
			$result = mysql_query($select);
			if($result)
			{
				while($row = mysql_fetch_array($result))
				{
					if(is_file($row['path']))
					{
						self::setId($row['id']);
						self::setSiteId($row['site_id']);
						self::setSetId($row['set_id']);
						self::setModId($row['mod_id']);
						self::setNameL($row['name_l']);
						self::setNameR($row['name_r']);
						self::setHFB($row['hfb_set']);
						self::setIcon($row['icon']);
						self::setPath($row['path']);
						self::setActive($row['active']);
					}
					else
					{ 
						self::setId(0); 
						self::setModId(0);
					}
				}
			}
		}
	}
	
	public function addFormError($error, $field = 'general')
	{
		if($error != '')
		{ $this->FormError[$field] = $error; }
	}
	
	public function addFormInfo($info, $field = 'general')
	{
		if($info)
		{ $this->FormError[$field] = $info; }
	}
}
?>